/*     */ package com.zimbra.cs.service.admin;
/*     */ 
/*     */ import com.zimbra.common.account.Key.DistributionListBy;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.AdminConstants;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.cs.account.DistributionList;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*     */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*     */ import com.zimbra.soap.JaxbUtil;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import com.zimbra.soap.admin.message.GetDistributionListMembershipRequest;
/*     */ import com.zimbra.soap.admin.type.DistributionListSelector;
/*     */ import com.zimbra.soap.admin.type.DistributionListSelector.DistributionListBy;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class GetDistributionListMembership
/*     */   extends AdminDocumentHandler
/*     */ {
/*     */   public boolean domainAuthSufficient(Map context)
/*     */   {
/*  50 */     return true;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean defendsAgainstDelegateAdminAccountHarvesting()
/*     */   {
/*  58 */     return true;
/*     */   }
/*     */   
/*     */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*     */   {
/*  63 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*  64 */     Provisioning prov = Provisioning.getInstance();
/*  65 */     GetDistributionListMembershipRequest req = (GetDistributionListMembershipRequest)JaxbUtil.elementToJaxb(request);
/*     */     
/*  67 */     int limit = req.getLimit() == null ? 0 : req.getLimit().intValue();
/*  68 */     if (limit < 0) {
/*  69 */       throw ServiceException.INVALID_REQUEST("limit" + limit + " is negative", null);
/*     */     }
/*  71 */     int offset = req.getOffset() == null ? 0 : req.getOffset().intValue();
/*  72 */     if (offset < 0) {
/*  73 */       throw ServiceException.INVALID_REQUEST("offset" + offset + " is negative", null);
/*     */     }
/*     */     
/*  76 */     DistributionListSelector dlSel = req.getDl();
/*  77 */     Key.DistributionListBy dlBy = dlSel.getBy().toKeyDistributionListBy();
/*  78 */     String dlKey = dlSel.getKey();
/*     */     
/*  80 */     DistributionList distributionList = prov.get(dlBy, dlKey);
/*  81 */     defendAgainstGroupHarvesting(distributionList, dlBy, dlKey, zsc, Rights.Admin.R_getDistributionListMembership, Rights.Admin.R_getDistributionListMembership);
/*     */     
/*     */ 
/*     */ 
/*  85 */     HashMap<String, String> via = new HashMap();
/*  86 */     List<DistributionList> lists = prov.getDistributionLists(distributionList, false, via);
/*     */     
/*  88 */     Element response = zsc.createElement(AdminConstants.GET_DISTRIBUTION_LIST_MEMBERSHIP_RESPONSE);
/*  89 */     for (DistributionList dl : lists) {
/*  90 */       Element dlEl = response.addNonUniqueElement("dl");
/*  91 */       dlEl.addAttribute("name", dl.getName());
/*  92 */       dlEl.addAttribute("id", dl.getId());
/*  93 */       String viaDl = (String)via.get(dl.getName());
/*  94 */       if (viaDl != null) dlEl.addAttribute("via", viaDl);
/*     */     }
/*  96 */     return response;
/*     */   }
/*     */   
/*     */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*     */   {
/* 101 */     relatedRights.add(Rights.Admin.R_getDistributionListMembership);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetDistributionListMembership.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */